
const path = require('path')

let o = {};

o.myPath0 = path.join(__dirname,'/foo/bar')

o.myPath1 = path.join(__dirname,'./foo/bar')

o.myPath2 = path.resolve(__dirname,'/foo/bar')

o.myPath3 = path.resolve(__dirname,'foo/bar')

o.myPath4 = path.join(__dirname,'foo/bar')

console.log(__dirname)

for(let i = 0;i<5;i++) {
	console.log(o['myPath'+i])
}
// let i = 5
// while(i-- >-1) {
	// console.log(o['myPath'+i])
// 	console.log('i:'+i)
// }

console.log(path.resolve('foo/bar', '/tmp/file/', '..', 'a/../subfile'))

// 相当于执行以下命令
// $ cd foo/bar
// $ cd /tmp/file/
// $ cd ..
// $ cd a/../subfile
// $ pwd
// => D:\tmp\subfile

// console.log(myPath0)
// console.log(myPath1)
// console.log(myPath2)
// console.log(myPath3)

